import org.w3c.dom.Node;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;

public class Test {

    // 把 10w 个数据去重
    public static void main(String[] args) {
        int[] array = {1,2,3,4,5,6,7,2,3,4,5,4,5,8,2,1,1,7,3,6,6,6,6,6};
        HashSet<Integer> set = new HashSet<>();
        for (int i = 0; i < array.length; i++) {
            set.add(array[i]);
        }
        System.out.println(set);
    }

    public static void main3(String[] args) {
        int[] array = {1,2,3,4,5,6,7,2,3,4,5,4,5,8,2,1,1,7,3,6,6,6,6,6};
        HashMap<Integer,Integer> map = new HashMap<>();
        for (int i = 0; i < array.length; i++) {
            if(map.get(array[i]) == null) {
                map.put(array[i],1);
            }else {
                Integer val = map.get(array[i]);
                map.put(array[i],val+1);
            }
        }
    }

    private static void func(String str1, String str2) {
        //str1: 应该输出的文字
        //str2: 实际被输入的文字
        Set<Character> set1 = new HashSet<>();
        // set1 中装的是 str2 中每个实际被输入的文字，转为大写，可能有重复
        for(char ch : str2.toUpperCase().toCharArray()) {
            set1.add(ch);
        }

        //存入缺少的
        Set<Character> setBroken = new HashSet<>();
        for (char ch : str1.toUpperCase().toCharArray()) {
            //得避免重复
            if(!set1.contains(ch) && !setBroken.contains(ch)) {
                System.out.print(ch);
                setBroken.add(ch);
            }
        }
    }

    public int numJewelInStones(String jewels, String stones) {
        HashSet<Character> set = new HashSet<>();
        for (int i = 0; i < jewels.length(); i++) {
            char ch = jewels.charAt(i);
            set.add(ch);
        }
        int count = 0;
        for (int i = 0; i < stones.length(); i++) {
            char ch = stones.charAt(i);
            if(set.contains(ch)) {
                count++;
            }
        }
        return count;
    }

    public int singleNumber(int[] nums) {
        HashSet<Integer> set = new HashSet<>();

        for (int i = 0; i < nums.length; i++) {
            if(set.contains(nums[i])) {
                set.remove(nums[i]);
            }else {
                set.add(nums[i]);
            }
        }

        for (int i = 0; i < nums.length; i++) {
            if(set.contains(nums[i])) {
                return nums[i];
            }
        }
        return -1;
    }

    public static void main2(String[] args) {
        HashMap<Integer,Integer> map  = new HashMap<>();
        map.put(1,1111);

        HashSet<Integer> set = new HashSet<>();
        set.add(10);
    }

    public static void main1(String[] args) {
        Person p = new Person("123");
        Person p2 = new Person("123");

        HashBuck<Person,String> hashBuck = new HashBuck<>();
        hashBuck.put(p,"小比特");

        System.out.println(hashBuck.get(p2));
    }
}
